<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: include/pico/critical_section.h Source File</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.0.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('critical__section_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">critical_section.h</div></div>
</div><!--header-->
<div class="contents">
<a href="critical__section_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * SPDX-License-Identifier: BSD-3-Clause</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> */</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span> </div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="preprocessor">#ifndef _PICO_CRITICAL_SECTION_H</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#define _PICO_CRITICAL_SECTION_H</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &quot;<a class="code" href="lock__core_8h.html">pico/lock_core.h</a>&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span> </div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span> </div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"><a class="line" href="structcritical__section.html">   29</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span>__packed_aligned <a class="code hl_struct" href="structcritical__section.html">critical_section</a> {</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span>    spin_lock_t *spin_lock;</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span>    uint32_t save;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span>} critical_section_t;</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span> </div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__critical__section.html#ga22cd2722a96179036820e87b29209cfd">critical_section_init</a>(critical_section_t *crit_sec);</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span> </div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__critical__section.html#gae1b4eb5dcab9ac679970ac43d618de2c">critical_section_init_with_lock_num</a>(critical_section_t *crit_sec, uint lock_num);</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span> </div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"><a class="line" href="group__critical__section.html#ga15e4552b4e1419faad51eba026a39aad">   61</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__critical__section.html#ga15e4552b4e1419faad51eba026a39aad">critical_section_enter_blocking</a>(critical_section_t *crit_sec) {</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>    crit_sec-&gt;save = <a class="code hl_function" href="group__hardware__sync.html#ga091e88a7608ed8dbf3e1e984bae54602">spin_lock_blocking</a>(crit_sec-&gt;spin_lock);</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>}</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"><a class="line" href="group__critical__section.html#gab57fcee3973b26dced4601e6018a227c">   70</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__critical__section.html#gab57fcee3973b26dced4601e6018a227c">critical_section_exit</a>(critical_section_t *crit_sec) {</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>    <a class="code hl_function" href="group__hardware__sync.html#ga281ce69786da23cab7ba6c42537d4e87">spin_unlock</a>(crit_sec-&gt;spin_lock, crit_sec-&gt;save);</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span>}</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span> </div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__critical__section.html#ga08444ba7879fae8813dd5573a13f0351">critical_section_deinit</a>(critical_section_t *crit_sec);</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span> </div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"><a class="line" href="group__mutex.html#ga0be65abf0782a68a724bd6d37fd5e010">   91</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="group__mutex.html#ga0be65abf0782a68a724bd6d37fd5e010">critical_section_is_initialized</a>(critical_section_t *crit_sec) {</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>    <span class="keywordflow">return</span> crit_sec-&gt;spin_lock != 0;</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>}</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span> </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>}</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="agroup__critical__section_html_ga08444ba7879fae8813dd5573a13f0351"><div class="ttname"><a href="group__critical__section.html#ga08444ba7879fae8813dd5573a13f0351">critical_section_deinit</a></div><div class="ttdeci">void critical_section_deinit(critical_section_t *crit_sec)</div><div class="ttdoc">De-Initialise a critical_section created by the critical_section_init method.</div><div class="ttdef"><b>Definition:</b> critical_section.c:22</div></div>
<div class="ttc" id="agroup__critical__section_html_ga15e4552b4e1419faad51eba026a39aad"><div class="ttname"><a href="group__critical__section.html#ga15e4552b4e1419faad51eba026a39aad">critical_section_enter_blocking</a></div><div class="ttdeci">static void critical_section_enter_blocking(critical_section_t *crit_sec)</div><div class="ttdoc">Enter a critical_section.</div><div class="ttdef"><b>Definition:</b> critical_section.h:61</div></div>
<div class="ttc" id="agroup__critical__section_html_ga22cd2722a96179036820e87b29209cfd"><div class="ttname"><a href="group__critical__section.html#ga22cd2722a96179036820e87b29209cfd">critical_section_init</a></div><div class="ttdeci">void critical_section_init(critical_section_t *crit_sec)</div><div class="ttdoc">Initialise a critical_section structure allowing the system to assign a spin lock number.</div><div class="ttdef"><b>Definition:</b> critical_section.c:13</div></div>
<div class="ttc" id="agroup__critical__section_html_gab57fcee3973b26dced4601e6018a227c"><div class="ttname"><a href="group__critical__section.html#gab57fcee3973b26dced4601e6018a227c">critical_section_exit</a></div><div class="ttdeci">static void critical_section_exit(critical_section_t *crit_sec)</div><div class="ttdoc">Release a critical_section.</div><div class="ttdef"><b>Definition:</b> critical_section.h:70</div></div>
<div class="ttc" id="agroup__critical__section_html_gae1b4eb5dcab9ac679970ac43d618de2c"><div class="ttname"><a href="group__critical__section.html#gae1b4eb5dcab9ac679970ac43d618de2c">critical_section_init_with_lock_num</a></div><div class="ttdeci">void critical_section_init_with_lock_num(critical_section_t *crit_sec, uint lock_num)</div><div class="ttdoc">Initialise a critical_section structure assigning a specific spin lock number.</div><div class="ttdef"><b>Definition:</b> critical_section.c:17</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga091e88a7608ed8dbf3e1e984bae54602"><div class="ttname"><a href="group__hardware__sync.html#ga091e88a7608ed8dbf3e1e984bae54602">spin_lock_blocking</a></div><div class="ttdeci">static __force_inline uint32_t spin_lock_blocking(spin_lock_t *lock)</div><div class="ttdoc">Acquire a spin lock safely.</div><div class="ttdef"><b>Definition:</b> spin_lock.h:301</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga281ce69786da23cab7ba6c42537d4e87"><div class="ttname"><a href="group__hardware__sync.html#ga281ce69786da23cab7ba6c42537d4e87">spin_unlock</a></div><div class="ttdeci">static __force_inline void spin_unlock(spin_lock_t *lock, uint32_t saved_irq)</div><div class="ttdoc">Release a spin lock safely.</div><div class="ttdef"><b>Definition:</b> spin_lock.h:332</div></div>
<div class="ttc" id="agroup__mutex_html_ga0be65abf0782a68a724bd6d37fd5e010"><div class="ttname"><a href="group__mutex.html#ga0be65abf0782a68a724bd6d37fd5e010">critical_section_is_initialized</a></div><div class="ttdeci">static bool critical_section_is_initialized(critical_section_t *crit_sec)</div><div class="ttdoc">Test whether a critical_section has been initialized.</div><div class="ttdef"><b>Definition:</b> critical_section.h:91</div></div>
<div class="ttc" id="alock__core_8h_html"><div class="ttname"><a href="lock__core_8h.html">lock_core.h</a></div></div>
<div class="ttc" id="astructcritical__section_html"><div class="ttname"><a href="structcritical__section.html">critical_section</a></div><div class="ttdef"><b>Definition:</b> critical_section.h:29</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>